<admintpl file="header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="{:U('Admin/LivePushOperator/index')}">推流业务员列表</a></li>
			<li><a href="{:U('Admin/LivePushOperator/add')}">添加推流业务员</a></li>
		</ul>
		<form class="well form-search" id="query_form" method="post" action="{:U('Admin/LivePushOperator/index')}">
			姓名： 
			<input type="text" name="name" style="width: 120px;" value="{$formParam.name}" placeholder="业务员姓名...">
			账号： 
			<input type="text" name="mobile_phone" style="width: 120px;" value="{$formParam.mobile_phone}" placeholder="业务员账号...">
			状态： 
			<select class="select_2" name="status" style="width: 90px;">
				<option value='-1'>全部</option>
				<option value='1' <if condition="$formParam.status eq 1"> selected </if>>启用</option>
				<option value='0' <if condition="$formParam.status eq 0"> selected </if>>停用</option>
			</select>
			<input type="button" name="query_form_btn" id="queryBtn" data-action="{:U('Admin/LivePushOperator/index')}" class="btn btn-primary" value="查询" />
		</form>
		<form class="js-ajax-form" action="" method="post">
		<table class="table table-hover table-bordered">
			<thead>
				<tr>
					<th>姓名</th>
					<th>账号</th>
					<th>状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<php>
					 $status = array("0"=>'停用',"1"=>'启用');
				</php>
				<foreach name="data" item="vo">
				<tr>
					<td>{$vo.real_name}
					<a style="float:right;" href='javascript:void(1);' onclick='edit_real_name({$vo["operator_id"]},"{$vo.real_name}")' >修改</a>
					</td>
					<td>{$vo.mobile_phone}</td>
					<td>{$status[$vo['status']]}</td>
					<td>
					    <a href='javascript:void(1);' onclick='reset_pwd({$vo["operator_id"]})'>重置密码</a>
						<if condition="$vo.status eq 1"> 
							<a href='{:U("Admin/LivePushOperator/disable",array("operator_id"=>$vo["operator_id"]))}' class="js-ajax-dialog-btn">停用</a>
						</if>
						<if condition="$vo.status eq 0"> 
							<a href='{:U("Admin/LivePushOperator/enable",array("operator_id"=>$vo["operator_id"]))}' class="js-ajax-dialog-btn">启用</a>
						</if>
						<a href='{:U("Admin/LivePushOperator/delete",array("operator_id"=>$vo["operator_id"]))}' class="js-ajax-dialog-btn">删除</a>
					</td>
				</tr>
				</foreach>
			</tbody>
		</table>
		</form>
		<div class="pagination">{$page}</div>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/ueditor/third-party/zeroclipboard/ZeroClipboard.min.js"></script>
	<script src="__PUBLIC__/js/layer/layer.js"></script>
	<script>
	$(document).ready(function(){
		$('input[name="query_form_btn"]').click(function(){
			 $('#query_form').attr('action', $(this).attr('data-action'));
			 $('#query_form').submit();
		});
		var clip = new ZeroClipboard($("td .link_url"));
		clip.on("aftercopy", function(e){
		    alert('复制成功！');
		});
	});
	function edit_real_name(operator_id, name){
		//prompt层
		 layer.prompt({
		   title: '输入姓名',
		   value:name,
		   formType: 0 //prompt风格，支持0-2
		 }, function(real_name){
			 if(null == real_name || '' == real_name){
				 layer.msg('姓名不能为空！');
				 return;
			 }
			 $.post('{:U("Admin/LivePushOperator/edit_real_name")}', {operator_id:operator_id, real_name:real_name}, function(result){
				 if(result.status == '1'){
					$('input[name="query_form_btn"]').click();
				 	layer.msg('修改成功！');
				 }
		     });
		 });
	}
	function reset_pwd(operator_id){
		//prompt层
		 layer.prompt({
		   title: '输入新密码',
		   formType: 1 //prompt风格，支持0-2
		 }, function(pwd){
			 if(null == pwd || '' == pwd){
				 layer.msg('密码不能为空！');
				 return;
			 }
			 if(pwd.length < 6){
				 layer.msg('密码必须为6个以上字符！');
				 return;
			 }
			 $.post('{:U("Admin/LivePushOperator/reset_pwd")}',{operator_id:operator_id, password:pwd},function(result){
				 if(result.status == '1'){
					 layer.msg('修改成功！');
				 }
		     });
		 });
	}
	</script>
</body>
</html>